# -*-coding utf-8 -*-

__project__ = 'le-bo16'
__file_name__ = 'homework5'
__author__ = 'hqDu'
__time__ = '2020-11-06 22:45'
__product_name = 'PyCharm'
# @fileName :homework3.py

import random  # 需要顶头写，否则有下波浪线
"""
列表实现猜拳,三局两胜，玩家累计输入错误超过并包括3次，就会停止游戏
"""
# gestures = ['石头', '剪刀', '布']  # 手势：石头、剪刀、布
# playerWin = 0  # 玩家获胜次数
# computerWin = 0  # 电脑获胜次数
# gameRound = 0  # 有效比赛总次数
# dogfallCount = 0  # 平局次数
# playerWrongInputCount = 0  # 玩家输入错误的次数

# while gameRound < 3  and (playerWin < 2 or computerWin < 2) and (playerWin + computerWin + dogfallCount < 3):
# 	player = input('请玩家输入石头、剪刀、布 : ')  # 玩家输入手势
# 	computer = random.choice(gestures)  # 电脑输入手势，随机从手势中选取一种
# 	print('电脑输入 ： %s ' % computer)
# 	if player in gestures:
# 		gameRound += 1  # 有效比赛总次数加1
# 		if(player == computer):  # 平局
# 			print('第%d局，平局' % gameRound)
# 			dogfallCount += 1  # 平局次数加1
# 		elif (player == '石头' and computer == '剪刀') or (player == '剪刀' and computer == '布') or (player == '布' and computer == '石头'):
# 			print('第%d局，玩家获胜' % gameRound)
# 			playerWin += 1  # 玩家胜，玩家获胜次数加1
# 		else:
# 			print('第%d局，电脑获胜' % gameRound)
# 			computerWin += 1  # 电脑胜，电脑获胜次数加1
# 	else:
# 		playerWrongInputCount += 1  # 玩家输入空或其他非空无效数据，玩家错误输入次数加1
# 		if playerWrongInputCount < 3:
# 			print('玩家第%d次输入错误信息，请重新输入石头、剪刀或布' % playerWrongInputCount)
# 		else:
# 			break
#
# if playerWrongInputCount == 3:
# 	print("玩家错误输入次数已达到上限（3次），猜拳游戏结束")
# elif playerWin == 2 or (dogfallCount == 2 and playerWin == 1):  # 玩家胜两局，或平两局胜一局
# 	print("三局两胜，最终玩家胜")
# elif computerWin == 2 or (dogfallCount == 2 and computerWin == 1):  # 电脑胜两局，或平两局胜一局
# 	print("三局两胜，最终电脑胜")
# else:
# 	print("三局两胜，最终平局")


"""
一个学校，三个办公室，八位老师，随机分配办公室；N个办公室，M个老师,手动输入老师名字，然后len
"""

# offices = [[], [], []]  # 定义嵌套空列表，第一层存储3个办公室，第二层存储每个办公室内老师
# teachers = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']  # 8位老师
#
# a = list("ABCDEFGH")
# a = list("[][][]")  # ['[', ']', '[', ']', '[', ']']，把每一个元素都当做需要分割的符号
# print(a)
#
# for teacher in teachers:
#     index = random.randint(0, 2)  # 从0,1,2中随机为每位老师分配分配办公室编号，即为offices下标
#     offices[index].extend(teacher)  # 把每位老师按照编号存储到对应办公室内
# for office in offices:  # 打印每个办公室内老师
#     print("第%d个办公室的老师有：", end=' ')
#     for i in range(len(office)):
#         print(office[i], end= ' ')
#     print()

# a = ['','','','','','','','','',''] 变成 []
# b = ['','','','','','1','','','',''] 变成 ['1']

# for i in range(0,6):
#     for j in range(0,10):
#         if offices[i][j] == '':
#             office[i].pop(j)

"""
任意编程语言循环输出0至10
"""
# res = 0  # 和
# for i in range(11):
#     res += i
# print(res)


"""
逆序输出字符串，如【欢乐逛欢迎您】，【您迎欢逛乐欢】
"""
# str1 = "欢乐逛欢迎您"
# str2 = str1[::-1]
# print(str2)


"""
str = 'a,hello' 在字符串str中查找hello;  
find()  下标或-1 
index() 下标或报错
会返回索引下标，但是用于判断是否存在可以用count()
"""
# str1 = 'hello,adds'
# if str1.count("hello"):
#     print("存在")
# else:
#     print("不存在")
# print(str1.find(hello))

"""
str = 'a,b,c,d'，用逗号分割str字符串，并保存到列表
"""
# str1 = 'a,b,c,d'
# my_list = str1.split(',')
# print(my_list)
# my_str = ' '.join(my_list)
# print(my_str)

"""
将'笔试题123A'中'123'替换为'进行中'
"""
# str1 = '笔试题123A'
# str2 = str1.replace('123','进行中')
# print(str2)


